//
//  XueShengDetailHeaderView.m
//  SanYiTeaching
//
//  Created by 李文强 on 2019/4/16.
//  Copyright © 2019 SanYi. All rights reserved.
//

#import "XueShengDetailHeaderView.h"
#import "MinButtonViewBtn.h"

@implementation XueShengDetailHeaderView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (instancetype)initWithFrame:(CGRect)frame{
    if ([super initWithFrame:frame]) {
        [self initSubView];
    }
    return self;
}
- (void)initSubView{
    [self addSubview:self.headerImageView];
    [_headerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX);
        make.top.equalTo(@0).offset(25*fh);
        make.height.equalTo(@70);
        make.width.equalTo(@70);
    }];
    [self addSubview:self.nameLabel];
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.headerImageView.mas_centerX);
        make.top.equalTo(self.headerImageView.mas_bottom).offset(10);
        make.width.equalTo(@200);
        make.height.equalTo(@15);
    }];
    [self addSubview:self.backView];
    [_backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX);
        make.width.equalTo(@0).offset(530*fw);
        make.height.equalTo(@0).offset(202*fh);
        make.top.equalTo(self.nameLabel.mas_bottom).offset(30);
    }];
    CGFloat W =(530*fw)/3;
    NSArray *titleArray = @[@"作业",@"测试",@"考勤",@"辅导",@"补课",@"通知"];
    NSArray *imageArray = @[@"zuoYe",@"ceshi_studetCenter",@"kaoQing_StudenCenter",@"fuDao_studentCenter",@"buKe_studentCenter",@"tongZhi_studentCenter"];
    for (int i = 0; i<6; i++) {
        MinButtonViewBtn *btn = [[MinButtonViewBtn alloc]initWithFrame:CGRectMake(0, 0, 177*fw, 100*fh) andType:ButtonImageInTop];
        btn.frame = CGRectMake(W*(i%3), i/3*100*fh, 177*fw, 100*fh);
        btn.bottomLabel.text = titleArray[i];
        btn.topImage.image = [UIImage imageNamed:imageArray[i]];
        [btn.topImage mas_updateConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(@34);
            make.height.equalTo(@39);
        }];
        [_backView addSubview:btn];
    }
}
- (UIView *)backView{
    if (!_backView) {
        UIView *view = [[UIView alloc]init];
        _backView = view;
    }
    return _backView;
}
- (UIImageView *)headerImageView{
    if (!_headerImageView) {
        UIImageView *view = [[UIImageView alloc]init];
        view.backgroundColor = [UIColor whiteColor];
        view.layer.cornerRadius = 35;
        view.layer.masksToBounds = YES;
        _headerImageView = view;
    }
    return _headerImageView;
}
- (UILabel *)nameLabel{
    if (!_nameLabel) {
        UILabel *label = [[UILabel alloc] init];
        label.frame = CGRectMake(330.5,79.5,140.5,13);
        label.numberOfLines = 0;
        label.text = @"单茹";
        label.textAlignment = 1;
        label.font = [UIFont systemFontOfSize:14];
        label.textColor = TITLECOLOR;
        _nameLabel = label;
    }
    return _nameLabel;
}
@end
